﻿//using Microsoft.Extensions.DependencyInjection;
//using Sgr.Exceptions;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace Sgr.Domain.Uow
//{
//    /// <summary>
//    /// 默认工作单元提供者实现
//    /// </summary>
//    public class DefaultUnitOfWorkProvider : IUnitOfWorkProvider
//    {
//        private readonly IServiceProvider _serviceProvider;

//        public DefaultUnitOfWorkProvider(IServiceProvider serviceProvider)
//        {
//            _serviceProvider = serviceProvider;
//        }

//        public IUnitOfWork GetUnitOfWork(string moduleName)
//        {
//            foreach (var unitOfWork in _serviceProvider.GetServices<IUnitOfWork>())
//            {
//                if (string.Equals(unitOfWork.ModuleName, moduleName, StringComparison.OrdinalIgnoreCase))
//                {
//                    return unitOfWork;
//                }
//            }

//            throw new BusinessException($"找不到模块名为'{moduleName}'的工作单元");
//        }
//    }
//}